﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebFormsMvp.Web;
using MusicWorks.Web.Logic.Views;

namespace MusicWorks.Web.Controls
{
    public partial class LoginControl : MvpUserControl, ILoginView
    {
        protected void Login_Authenticate(object sender, System.Web.UI.WebControls.AuthenticateEventArgs e)
        {
            var args = new Logic.Views.AuthenticateEventArgs();
            OnAuthenticate(args);
            e.Authenticated = args.IsAuthenticated;
        }

        protected virtual void OnAuthenticate(Logic.Views.AuthenticateEventArgs authenticateEventArgs)
        {
            if (Authenticate != null) Authenticate(this, authenticateEventArgs);
        }

        public string UserName
        {
            get { return Login.UserName; }
        }

        public string Password
        {
            get { return Login.Password; }
        }

        public event EventHandler<Logic.Views.AuthenticateEventArgs> Authenticate;
    }
}